package cn.zxy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

//@Configuration 说明是配置类
@Configuration

@ConditionalOnWebApplication  //  web应用才生效
@EnableConfigurationProperties(HelloProperties.class)

//也可以使用@Import
//@Import(HelloProperties.class)
public class HelloServiceAutoconfiguration {

    @Autowired
    HelloProperties helloProperties;

    @Bean
    public HelloService helloService(){
        HelloService service=new HelloService();
        service.setHelloProperties(helloProperties);
        return service;
    }

}
